<template>
  <div class="container">
    <div class="logo-content">
      <img v-if="logoFlag"
           src="../assets/images/logoA.png"
           width="60%">
      <img :src="logoUrl"
           v-if="!logoFlag">
    </div>
    <div class="nav-content">
      <button class="button-nav"
              @click="goToNewPage('/index',1)">案场助手</button>
      <button class="button-nav"
              @click="goToNewPage('/org/orgIndex',2)">渠道管理</button>
      <button class="button-nav"
              @click="goToNewPage('/premisesList',3)">楼盘分享</button>
      <button class="button-nav position-relative"
              @click="goToNewPage('/bossBoardTop',4)">Boss看板<span class="new-label">NEW</span></button>

    </div>
  </div>
</template>

<script>
import { Toast } from "mint-ui";
export default {
  name: "index-nav",
  data() {
    return {
      logoFlag: true,
      logoUrl: "",
    };
  },
  mounted() {
    this.getCompanyLogo();
  },
  methods: {
    getCompanyLogo() {
      var _self = this;
      var body = {};
      body.params = { logoType: "2" };
      var url = _self.utilHelper.apiUrl + "/api/getLogo";
      _self.$http.post(url, body).then((response) => {
        var data = response.body.resData;
        if (data.result == "1") {
          _self.logoFlag = false;
          _self.logoUrl = data.logoUrl;
        }
      });
    },
    goToNewPage(path, type) {
      let menuCode = "";
      let auth = false;
      if (type == 1) {
        menuCode = "menu_0008";
      } else if (type == 2) {
        menuCode = "menu_0010";
      } else if (type == 3) {
        menuCode = "menu_0011";
      } else if (type == 4) {
        menuCode = "menu_0013";
      }
      var res = JSON.parse(window.sessionStorage.getItem("2_resources"));
      if (res && res.length > 0) {
        for (var i = 0; i < res.length; i++) {
          if (menuCode == res[i]) {
            auth = true;
            break;
          }
        }
      }
      if (auth) {
        this.$router.push(path);
        this.showDialog = false;
      } else {
        Toast("您没有相应权限，请联系管理员开通");
      }
    },
  },
};
</script>

<style scoped>
.logo-content {
  text-align: center;
}
.logo-content img {
  width: 60%;
}
.nav-content {
  text-align: center;
  margin-top: 50px;
}
.button-nav {
  border: 2px solid #eb6100;
  color: #eb6100;
  width: 52%;
  height: 50px;
  margin-top: 30px;
  background: none;
  font-size: 16px;
  border-radius: 5px;
}
.position-relative {
  position: relative;
}
.new-label {
  background-color: rgba(255, 106, 106, 1);
  position: absolute;
  right: -10px;
  bottom: 35px;
  color: #fff;
  font-size: 12px;
  padding: 3px;
  border-radius: 5px;
}
</style>